<template>
  <div>
    <!--20191125需求说去掉
       <BreakSpace label="相关线索" :containerStyle="{ marginBottom: '10px' }"/>
    <FilterTable
      ref="table"
      height="auto"
      :columns="columns"
      :dataSource="cluesList"
      :isPagination='false'
      :isToperInfo='false'
      :isColumnFilter='false'
      :isSelectColumn='false'
      selectionType="single"
      :onColumnsChange="columns => this.columns = columns"
    ></FilterTable> -->
    <BreakSpace label="已介绍客户" :containerStyle="{ marginBottom: '10px' }"/>
    <FilterTable
      ref="table"
      height="auto"
      :columns="columns2"
      :dataSource="cluesList"
      :isPagination='false'
      :isToperInfo='false'
      :isColumnFilter='false'
      :isSelectColumn='false'
      selectionType="single"
      :onColumnsChange="columns2 => this.columns2 = columns2"
    ></FilterTable>
  </div>
</template>

<script>
import { getRelateAuditDistList } from '@/api/potenCus/customer/cust1Manage';
import { queryAboutClues } from '@/api/potenCus/customer/potenCusManage';
import { dictionary } from '@/utils/dictMixin';
import { formatDates } from '@/utils/validate';

export default {
  name: 'aboutClues',
  mixins: [dictionary],
  props: {
    type: {
      type: String,
      default: 'show'
    },
    rowData: {
      type: Object,
      default: () => ({})
    }
  },
  data() {
    this.saveData = null;
    return {
      cluesList: [],
      columns: this.createTableColumns(),
      clientsList: [],
      columns2: this.createTableColumns2(),
      handleType: '',
      formData: {},
    };
  },
  created() {
    this.init();
    this.getRelateAuditDistList()
  },
  methods: {
    init() {
        console.log('相关', this.rowData)
        // 更新接口需要的记录 ID
        this.potentialCustomersId = this.rowData.potentialCustomersId
        this.clueType = this.rowData.clueType
        // this.mobilePhone = this.rowData.mobilePhone;
        // this.customerBusinessId = this.rowData.customerBusinessId;
        // this.columns.forEach(x => {
        //   x.initialValue = this.rowData[x.fieldName];
        // });
    },
    createTableColumns() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '客户名称',
          dataIndex: 'customerName',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '客户类型',
          dataIndex: 'customerType',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: this.createDictList('1523'),
          render: props => {
            return <span>{this.createDictText(props.row.customerType, '1523')}</span>;
          }
        },
        {
          title: '联系人姓名',
          dataIndex: 'contactName',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '性别',
          dataIndex: 'gender',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: this.createDictList('1002'),
          render: props => {
            return <span>{this.createDictText(props.row.gender, '1002')}</span>;
          }
        },
        {
          title: '手机号码',
          dataIndex: 'mobilePhone',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '潜客状态',
          dataIndex: 'clueStatus',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: this.createDictList('7000'),
          render: props => {
            return <span>{this.createDictText(props.row.clueStatus, '7000')}</span>;
          }
        },
        {
          title: '来源大类',
          dataIndex: 'clueSourceNameBig',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '来源细分',
          dataIndex: 'clueSourceNameSmall',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '意向品牌',
          dataIndex: 'inteBrandName',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '意向车系',
          dataIndex: 'inteCarSeriesName',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '意向车型',
          dataIndex: 'inteCarTypeName',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '意向级别',
          dataIndex: 'intentLevel',
          sorter: true,
          filter: true,
          filterType: 'input',
          align: 'center',
          render: props => {
            return <span>{this.createDictText(props.row.intentLevel, '1519')}</span>;
          }
        },
        {
          title: '是否下发',
          dataIndex: 'manufacturerIssue',
          sorter: true,
          filter: true,
          align: 'center',
          filterType: 'checkbox',
          filterItems: this.createDictList('1004'),
          render: props => {
            return <span>{this.createDictText(props.row.manufacturerIssue, '1004')}</span>;
          }
        },
        {
          title: '是否进店',
          dataIndex: 'shop',
          sorter: true,
          filter: true,
          align: 'center',
          filterType: 'input',
          // render: props => {
          //   return <span>{props.row.shop ==true?'是':'否'}</span>;
          // }
        },
        {
          title: '销售顾问',
          dataIndex: 'consultantName',
          sorter: true,
          filter: true,
          align: 'center',
          filterType: 'input',
        },
      ];
    },
    createTableColumns2() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '客户名称',
          dataIndex: 'customerName',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '客户类型',
          dataIndex: 'customerType',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: this.createDictList('1523'),
          render: props => {
            return <span>{this.createDictText(props.row.customerType, '1523')}</span>;
          }
        },
        {
          title: '联系人姓名',
          dataIndex: 'contactName',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '性别',
          dataIndex: 'gender',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: this.createDictList('1002'),
          render: props => {
            return <span>{this.createDictText(props.row.gender, '1002')}</span>;
          }
        },
        {
          title: '手机号码',
          dataIndex: 'mobilePhone',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '来源大类',
          dataIndex: 'clueSourceNameBig',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '来源细分',
          dataIndex: 'clueSourceNameSmall',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '意向级别',
          dataIndex: 'intentLevel',
          sorter: true,
          filter: true,
          align: 'center',
          filterType: 'input',
          render: props => {
            return <span>{this.createDictText(props.row.intentLevel, '1519')}</span>;
          }
        },
        {
          title: '是否进店',
          dataIndex: 'isArrived',
          sorter: true,
          filter: true,
          align: 'center',
          filterType: 'input',
          render: props => {
            return <span>{this.createDictText(props.row.isArrived, '1004')}</span>;
          }
        },
        {
          title: '销售顾问',
          dataIndex: 'consultant',
          sorter: true,
          filter: true,
          align: 'center',
          filterType: 'input',
        },
        {
          title: '意向车系',
          dataIndex: 'inteCarSeriesName',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
      ];
    },
    async getRelateAuditDistList() {
      if(this.potentialCustomersId){
          const res = await getRelateAuditDistList(this.clueType,this.potentialCustomersId)
          // const res = await queryAboutClues(13214145414)
          console.log('相关线索', res)
          if (res.resultCode === 200) {
            this.cluesList = res.data;
          }
      }
    },
  }
};
</script>

<style lang="less" scoped>
.information{
  position: relative;
  .info{
    position: absolute;
    top: -10px;
    left: 13px;
  }
  .line{
    width: 6px;
    height: 20px;
    background: #1890FF;
    position: absolute;
    top: -10px;
    left: 0;
  }
  .el-divider--horizontal {
    display: block;
    height: 1px;
    width: 90.5%;
    margin: 20px 0 12px 92px;
}
}
</style>

